using JGSY.CMS.LowCode.Platform.Domain.Interfaces;

namespace JGSY.CMS.LowCode.Platform.Domain.Entities.Monitoring;

/// <summary>
/// 监控会话汇总实体
/// 聚合用户会话的整体性能数据
/// </summary>
public class MonitorSessionSummary : ITenantEntity
{
    /// <summary>
    /// 主键ID
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 会话ID - 唯一标识一个用户会话
    /// </summary>
    public string SessionId { get; set; } = string.Empty;

    /// <summary>
    /// 用户ID - 可选，用于用户维度的会话分析
    /// </summary>
    public string? UserId { get; set; }

    /// <summary>
    /// 会话开始时间 - JavaScript Date.now() 毫秒时间戳
    /// </summary>
    public long SessionStart { get; set; }

    /// <summary>
    /// 会话结束时间 - JavaScript Date.now() 毫秒时间戳
    /// </summary>
    public long? SessionEnd { get; set; }

    /// <summary>
    /// 会话持续时间 - 秒为单位
    /// </summary>
    public int? SessionDuration { get; set; }

    /// <summary>
    /// 页面浏览数
    /// </summary>
    public int PageViews { get; set; } = 0;

    /// <summary>
    /// 错误总数
    /// </summary>
    public int ErrorCount { get; set; } = 0;

    /// <summary>
    /// 平均最大内容绘制时间 (LCP)
    /// </summary>
    public decimal? AvgLCP { get; set; }

    /// <summary>
    /// 平均首次输入延迟 (FID)
    /// </summary>
    public decimal? AvgFID { get; set; }

    /// <summary>
    /// 平均累积布局偏移 (CLS)
    /// </summary>
    public decimal? AvgCLS { get; set; }

    /// <summary>
    /// 平均首次内容绘制 (FCP)
    /// </summary>
    public decimal? AvgFCP { get; set; }

    /// <summary>
    /// 平均首字节时间 (TTFB)
    /// </summary>
    public decimal? AvgTTFB { get; set; }

    /// <summary>
    /// 浏览器名称
    /// </summary>
    public string? BrowserName { get; set; }

    /// <summary>
    /// 浏览器版本
    /// </summary>
    public string? BrowserVersion { get; set; }

    /// <summary>
    /// 操作系统名称
    /// </summary>
    public string? OSName { get; set; }

    /// <summary>
    /// 操作系统版本
    /// </summary>
    public string? OSVersion { get; set; }

    /// <summary>
    /// 设备类型 - desktop, mobile, tablet
    /// </summary>
    public string? DeviceType { get; set; }

    /// <summary>
    /// 国家/地区
    /// </summary>
    public string? Country { get; set; }

    /// <summary>
    /// IP地址
    /// </summary>
    public string? IPAddress { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;

    /// <summary>
    /// 租户标识符
    /// </summary>
    public string TenantId { get; set; } = string.Empty;
}
